package com.rongc.client.freight.business.mine.view.activity;

import android.os.Bundle;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.rongc.client.core.utils.StringUtils;
import com.rongc.client.freight.ApiUrl;
import com.rongc.client.freight.R;
import com.rongc.client.freight.UniApplication;
import com.rongc.client.freight.base.BaseActivity;
import com.rongc.client.freight.base.view.widget.ProgressWebView;

import butterknife.Bind;

/**
 * Created by ccqx on 2017/7/20.
 */

public class HdActivity extends BaseActivity {
    @Bind(R.id.webview)
    ProgressWebView webview;
    String url;

    @Override
    public void initParams() {
        url = getIntent().getStringExtra("url");
    }

    @Override
    public void initView() {
        initToolbar("活动");
    }

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//		getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        webview.getSettings().setJavaScriptEnabled(true);
        webview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
        webview.getSettings().setSupportMultipleWindows(true);
//		webview.setWebViewClient(new WebViewClient());
        webview.setWebChromeClient(new WebChromeClient());
        webview.setWebViewClient(new WebViewClient(){

            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                if(url.contains("backClick")){
                    finish();
                    return true;
                }
                return false;
            }

        });
        if(StringUtils.isNotEmpty(url)){
            webview.loadUrl(url);
        }else{
            url = ApiUrl.getDefaultHost()+"active.html?userid="+ UniApplication.getInstance().getUserInfo().getUserId();
            webview.loadUrl(url);
        }
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_active_invite;
    }
}
